package com.yangyang.rpc.server;

import com.yangyang.rpc.db.StudentInfoCache;
import org.apache.hadoop.ipc.ProtocolSignature;

import java.io.IOException;

public class SNoRpcServer implements SNoProtocol {

    private final StudentInfoCache studentInfoCache;

    public SNoRpcServer(StudentInfoCache studentInfoCache) {
        this.studentInfoCache = studentInfoCache;
    }

    @Override
    public String echo(String value) {
        return this.studentInfoCache.getNameBySNo(value);
    }

    @Override
    public long getProtocolVersion(String s, long l) throws IOException {
        return versionID;
    }

    @Override
    public ProtocolSignature getProtocolSignature(String s, long l, int i) throws IOException {
        return new ProtocolSignature(getProtocolVersion(s, l), null);
    }
}
